<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- <title>Login</title>
<script type="text/javascript">
	function getXMLObject() //XML OBJECT
	{
		var xmlHttp = false;
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); // For Old Microsoft Browsers
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // For Microsoft IE 6.0+
			} catch (e2) {
				xmlHttp = false; // No Browser accepts the XMLHTTP Object then false
			}
		}
		if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
			xmlHttp = new XMLHttpRequest(); //For Mozilla, Opera Browsers
		}
		return xmlHttp; // Mandatory Statement returning the ajax object created
	}

	var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax object

	//++++++++++++++++++++++++++++++++++
	function loginFunction() {
		if (xmlhttp) {
			var user = document.getElementById("user");
			var pass = document.getElementById("pass");

			var url = "/Ecommerce2011/login.do?user=" + user.value + "&pass="
					+ pass.value;
			xmlhttp.open("POST", url, true);

			xmlhttp.onreadystatechange = handleServerResponse;
			xmlhttp.setRequestHeader('Content-Type',
					'application/x-www-form-urlencoded');

			xmlhttp.send(null);

		}
	}

	function handleServerResponse() {
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200) {

				if (xmlhttp.responseText == "ERROR - El usuario o la password son incorrectos") {

					document.getElementById('message').innerHTML = xmlhttp.responseText;
					//location.href = "view/HomeView.jsp"
					
				} else {

					location.href = "view/HomeView.jsp"
					//document.getElementById('message').innerHTML = xmlhttp.responseText;

				}
				//Update the HTML Form element
			} else {
				alert("Error during AJAX call. Please try again");
			}
		}
	}
</script>
</head>
 -->
<body>

	<form name="loginForm" method="post" action="login.do">
		<label for="user">Usuario</label> 
		<input type="text" name="user"/> 
		<br/> 
		<label for="pass">Clave</label> 
		<input type="password" name="pass"/> 
		<br/> 
		<input type="button" value="login" onclick="document.loginForm.submit();"/> 
		<br />
	</form>
	
</body>
</html>

